home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / DEMON / RISCOS2 / TCP_131S.ARC / h / global < prev    next >
Text File  |  1994-02-06  |  2KB  |  67 lines

  1. /* Global definitions used by every source file.
  2.  * Some may be compiler dependent.
  3.  */
  4.  
  5. #ifndef GLOBAL_H
  6. #define GLOBAL_H
  7.  
  8. /* Indexes into binmode in files.c; hook for compilers that have special
  9.  * open modes for binary files
  10.  */
  11. #define READ_BINARY     0
  12. #define WRITE_BINARY    1
  13. extern char *binmode[];
  14.  
  15. /* These two lines assume that your compiler's longs are 32 bits and
  16.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  17.  * but it doesn't matter if they're signed or unsigned.
  18.  */
  19. typedef long int32;             /* 32-bit signed integer */
  20. typedef unsigned short int16;   /* 16-bit unsigned integer */
  21. #define uchar(x) (x)
  22. #define MAXINT16 65535          /* Largest 16-bit integer */
  23.  
  24. /* Define null object pointer in case stdio.h isn't included */
  25. #ifndef NULL
  26. /* General purpose NULL pointer */
  27. #define NULL (void *)0
  28. #endif
  29. #define NULLCHAR (char *)0      /* Null character pointer */
  30. #define NULLFP   (int (*)())0   /* Null pointer to function returning int */
  31. #define NULLVFP  (void (*)())0  /* Null pointer to function returning void */
  32. #define NULLFILE (FILE *)0      /* Null file pointer */
  33.  
  34. /* General purpose function macros */
  35. #define min(x,y)        ((x)<(y)?(x):(y))       /* Lesser of two args */
  36. #define max(x,y)        ((x)>(y)?(x):(y))       /* Greater of two args */
  37.  
  38. /* Extract a short from a long */
  39. /* Hacked these to see if it speeds things up */
  40. #define hiword(x)       ((int16) ((x) >> 16) & 0xFFFF)
  41. #define loword(x)       ((int16) ((x) & 0xFFFF))
  42.  
  43. /* Extract a byte from a short */
  44. #define hibyte(x)       (((x) >> 8) & 0xff)
  45. #define lobyte(x)       ((x) & 0xff)
  46.  
  47. /* Extract nibbles from a byte */
  48. #define hinibble(x)     (((x) >> 4) & 0xf)
  49. #define lonibble(x)     ((x) & 0xf)
  50.  
  51. char *strdup(char *);           /* In MISC.H */
  52.  
  53. void *mem_malloc(unsigned int, char *, int);
  54. void *mem_calloc(unsigned int, unsigned int, char *, int);
  55. char *mem_strdup(char *, char *, int);
  56. void  mem_free(void *, char *, int);
  57.  
  58. #define      MEM_NORMAL
  59. #if !defined(MEM_NORMAL)
  60. #define malloc(u)       mem_malloc((u),__FILE__,__LINE__)
  61. #define calloc(u,v)     mem_calloc((u),(v),__FILE__,__LINE__)
  62. #define strdup(s)       mem_strdup((s),__FILE__,__LINE__)
  63. #define free(p)         mem_free((p),__FILE__,__LINE__)
  64. #endif
  65.  
  66. #endif
  67.